/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package project.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Wolf
 */
@NamedQueries({
    @NamedQuery(name="searchPNome", query="SELECT l FROM ListaAutor l WHERE UPPER(l.pNome) LIKE UPPER(:pNome)"),
    @NamedQuery(name="searchUNome", query="SELECT l FROM ListaAutor l WHERE UPPER(l.uNome) LIKE UPPER(:uNome)"),
    @NamedQuery(name="searchEmail", query="SELECT l FROM ListaAutor l WHERE UPPER(l.email) LIKE UPPER(:email)"),
    @NamedQuery(name="searchEmpresa", query="SELECT l FROM ListaAutor l WHERE UPPER(l.empresa) LIKE UPPER(:empresa)"),
})

@Entity
public class ListaAutor implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    private String email;
    
    @NotNull
    private String pNome;
    
    @NotNull
    private String uNome;
    
    @NotNull
    private String empresa;
    
    @ManyToMany(mappedBy = "listaAutores")
    private Collection<Submissao> submissoes;

    public ListaAutor() {
    }

    public ListaAutor(String email, String pNome, String uNome, String empresa, Collection<Submissao> submissoes) {
        this.email = email;
        this.pNome = pNome;
        this.uNome = uNome;
        this.empresa = empresa;
        this.submissoes = submissoes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getEmail() != null ? getEmail().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the email fields are not set
        if (!(object instanceof ListaAutor)) {
            return false;
        }
        ListaAutor other = (ListaAutor) object;
        if ((this.getEmail() == null && other.getEmail() != null) || (this.getEmail() != null && !this.email.equals(other.email))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "project.entity.listaAutor[ id=" + getEmail() + " ]";
    }

    /**
     * @return the pNome
     */
    public String getpNome() {
        return pNome;
    }

    /**
     * @param pNome the pNome to set
     */
    public void setpNome(String pNome) {
        this.pNome = pNome;
    }

    /**
     * @return the uNome
     */
    public String getuNome() {
        return uNome;
    }

    /**
     * @param uNome the uNome to set
     */
    public void setuNome(String uNome) {
        this.uNome = uNome;
    }

    /**
     * @return the empresa
     */
    public String getEmpresa() {
        return empresa;
    }

    /**
     * @param empresa the empresa to set
     */
    public void setEmpresa(String empresa) {
        this.empresa = empresa;
    }

    /**
     * @return the submissoes
     */
    public Collection<Submissao> getSubmissoes() {
        return submissoes;
    }

    /**
     * @param submissoes the submissoes to set
     */
    public void setSubmissoes(Collection<Submissao> submissoes) {
        this.submissoes = submissoes;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }
    
}
